package com.dhcc.sdc.cdss.controller;


import java.util.List;
import java.util.Map;


import com.dhcc.sdc.cdss.entity.SdcCdssTreamatchEntity;
import com.dhcc.sdc.cdss.service.ISdcCdssTreamatchService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.baomidou.mybatisplus.plugins.Page;
import com.dhcc.core.framework.base.controller.BaseController;
import com.dhcc.core.framework.base.warpper.EmptyWarpper;
import com.dhcc.core.framework.exception.BizException;
import com.dhcc.core.framework.exception.BizExceptionEnum;
import com.dhcc.core.framework.result.R;
import com.dhcc.core.framework.result.page.PageFactory;
import com.dhcc.core.framework.util.CommonUtil;




/**
 *
 *
 * @ClassName: SdcCdssTreamatchController
 * @Description: TODO
 * @author zhangdc
 * @date 2022-06-23 16:04:20
 */
@Controller
@RequestMapping("${sys.backendPath}/sds/sdccdsstreamatch")
public class SdcCdssTreamatchController extends BaseController {

    private String PREFIX = "/backend/sds/sdccdsstreamatch/";

    @Autowired
    private ISdcCdssTreamatchService sdcCdssTreamatchService;


    /**
     * 获取列表
     */
    @SuppressWarnings("unchecked")
    @RequestMapping(value = "/list")
    @ResponseBody
    public Object list(@RequestParam Map<String, Object> params) {
        Page<SdcCdssTreamatchEntity> page = new PageFactory<SdcCdssTreamatchEntity>().defaultPage();
        List<SdcCdssTreamatchEntity> result = this.sdcCdssTreamatchService.page(page,params);
        page.setRecords((List<SdcCdssTreamatchEntity>) new EmptyWarpper(result).warp());
        return R.packForBT(page);
    }

    /**
     * 新增
     */
    @RequestMapping(value = "/add")
    @ResponseBody
    public Object add(SdcCdssTreamatchEntity sdcCdssTreamatch) {
        if (CommonUtil.isOneEmpty(sdcCdssTreamatch)) {
            throw new BizException(BizExceptionEnum.REQUEST_NULL);
        }
        sdcCdssTreamatch.insert();
        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping(value = "/delete")
    @ResponseBody
    public Object delete(@RequestParam Long sdcCdssTreamatchId) {

        this.sdcCdssTreamatchService.deleteById(sdcCdssTreamatchId);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping(value = "/update")
    @ResponseBody
    public Object update(SdcCdssTreamatchEntity sdcCdssTreamatch) {
        if (CommonUtil.isOneEmpty(sdcCdssTreamatch)) {
            throw new BizException(BizExceptionEnum.REQUEST_NULL);
        }
        SdcCdssTreamatchEntity old = this.sdcCdssTreamatchService.selectById(sdcCdssTreamatch.getId());

        old.setItemId(sdcCdssTreamatch.getItemId());
        old.setOrderId(sdcCdssTreamatch.getOrderId());
        old.updateAllColumnById();
        return R.ok();
    }

}
